package com.framework.service.yhbservice.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.framework.dao.YHBDao.indexDao.YhbIndexMenuDao;
import com.framework.service.yhbservice.YhbIndexMenuService;
import com.framework.service.yhbservice.YhbUserService;
import com.framework.yhbEntity.Index.YhbIndexMenu;
import com.framework.yhbEntity.user.YhbUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

@Transactional(rollbackFor = Exception.class)
@Service("yhbIndexMenuService")
public class YhbIndexMenuServiceImpl extends ServiceImpl<YhbIndexMenuDao,YhbIndexMenu> implements YhbIndexMenuService {

    @Autowired
    private YhbUserService yhbUserService;

    @Override
    public List<YhbIndexMenu> getIndexMenu(String token) {
        YhbUser user = yhbUserService.queryUserByToken(token);
        List<String> orderColumn=new ArrayList<>();
        orderColumn.add("value");
        List<YhbIndexMenu> list = baseMapper.selectList(new EntityWrapper<YhbIndexMenu>()
                .eq("dept_id", user.getDeptId())
                .eq("state", 1)
                .orderAsc(orderColumn)
        );
        
        return list;
    }
}
